'''
Created on Apr 16, 2012

@author: Gangli
'''

import argparse; 
import re;
import sys;

logcodes = [];

def addlogcode(logcode):
    global logcodes;
    if logcode not in logcodes:
        logcodes.append(logcode);

def inlogcodelist(logcode):
    global logcodes;
    return (logcode in logcodes);

def linematches(line):
    mo = re.search("(\s+\d+\s+)(\d+)(\s+\d+\s+)", line);
    if mo is None:
        return True;
    
    logcode = int(mo.group(2));
    return inlogcodelist(logcode);

def extract(fin, fout):
    for line in fin:
        if linematches(line):
            fout.write(line);

if __name__ == '__main__':
    pass